package com.yunshipei.enterplorer.browser;

import android.content.Context;
import android.net.Uri;

import com.yunshipei.model.YspEvent;
import com.yunshipei.utils.BaseUtil;

import org.xwalk.core.XWalkView;

import io.rong.eventbus.EventBus;

public class HomeSearchWebViewClient extends BaseHomeWebViewClient {

    private String mHomeUrl;

    public HomeSearchWebViewClient(Context context, String homeUrl, XWalkView xWalkView) {
        super(context, xWalkView);
        mHomeUrl = homeUrl;
    }

    @Override
    public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
        String temp = Uri.decode(url);
        if (temp.equals(mHomeUrl)) {
            return super.shouldOverrideUrlLoading(view, url);
        }
        BaseUtil.hideKeyBoard(mContext);
        EventBus.getDefault().post(new YspEvent.StartBrowserEvent(url));
        return true;
    }
}
